package com.zcxy.fast.vo;

import cn.hutool.core.collection.CollectionUtil;
import com.zcxy.fast.entity.SysCategory;
import com.zcxy.fast.mybatisExtend.anotation.JoinColumn;
import com.zcxy.fast.mybatisExtend.anotation.OneToMany;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * 分类字典Vo对象
 *
 * @author zcc
 * @email  860474958@qq.com
 * @date   2020-12-25 17:39:33
 */
@Data
@ApiModel(value = "SysCategoryVo", description = "分类字典Vo")
public class SysCategoryVo  {


    @ApiModelProperty(value = " 主键", required = false)
    private String id ;


    @ApiModelProperty(value = " 编码", required = false)
    private String code ;


    @ApiModelProperty(value = " 分类名称", required = false)
    private String name ;


    @ApiModelProperty(value = " ", required = false)
    private String parentId ;

    private boolean hasChildren;

    @OneToMany(targetEntity = SysCategory.class)
    @JoinColumn(name = "id",referencedColumnName = "parent_id")
    private List<SysCategory> sysCategories;

    public boolean isHasChildren() {
        if(CollectionUtil.isNotEmpty(sysCategories)){
            return true;
        }
        return false;
    }
}
